import axios from 'axios';

const http = axios.create({
  baseURL: '/api',
  timeout: 10000,
  headers: {
    'Content-Type': 'application/json',
  },
});

// 请求拦截器
http.interceptors.request.use(
  (config) => {
      return config;
  },
  (error) => {
    console.error('Request interceptor error:', error);
    return Promise.reject(error);
  }
);

// 响应拦截器
http.interceptors.response.use(
  (response) => {
     return response;
  },
  (error) => {
   
    if (error.response?.status === 403) {
      console.error('403 Forbidden - CORS issue or authentication problem');
    }

    return Promise.reject(error);
  }
);

export { http };